#include <iostream>
using std::cout;
using std::endl;

class Base{
public:
    Base(){
        cout << "Base()" << endl;
    } 

    Base(long base)
    : _base(base)
    { cout << "Base(long)" << endl; }

    void print() const {
        /* cout << "Base::_data:" << _data << endl; */
        cout << "Base::_data:" << endl;
    }

    ~Base(){ cout << "~Base()" << endl; }
private:
    long _data = 23;
    long _base;
};



class Derived
: public Base
{
public:
    //派生类没有显式调用基类的构造时，会默认调用基类的默认构造
    Derived(long a,long c)
    : Base(a) //调用基类的构造，写的是基类的类名
    , _derived(c)
    {
        cout << "Derived(long * 3)" << endl;
    }

    void print(int x) const {
        /* cout << "Derived::_data:" << _data << endl; */
        cout << "Derived::_data:" << endl;
    }

    ~Derived(){ cout << "~Derived()" << endl; }
private:
    long _data = 24;
    long _derived;
};

void test0(){
    Derived _d1(1,2);
    //不符合面向对象的原则，不推荐
    /* _d1.Base::print(); */

    //当派生类定义了与基类同名的成员函数时，只有名字相同
    //即使参数列表不同，也只能看到派生类的函数，
    //无法调用基类的同名函数，称之为隐藏
    _d1.print(100);
}

int main(void){
    test0();
    return 0;
}
